iT邦幫忙

2025 iThome 鐵人賽

DAY 22
0
Mobile Development

結合AI Agent技術打造自己的行程管家系列 第 22

Day 22 行程管家的外貌:景點推薦的其他功能

  • 分享至 

  • xImage
  •  

今天,我們的「景點推薦」正式進化升級!
在這個階段,我讓行程管家的「景點推薦」功能,不再只是靜態的圖片展示,而是能夠「互動」起來。
現在,只要使用者輕輕點擊圖片,就能立即跳出一個對話框,查看該景點的詳細介紹、開放時間、交通方式與票價資訊。

這樣的互動設計,讓介面更加生動、直覺,也讓整體使用體驗更貼近旅遊規劃的真實情境。
更重要的是,這項改版替未來的「行程規劃」與「景點收藏」功能打下了穩固的基礎。

這次展示的景點,分別代表了台中地區三個極具特色的人氣地標:

  • 麗寶樂園 — 刺激又充滿歡笑的遊樂天堂,結合主題樂園、Outlet 與度假村。
  • 落羽松森林 — 夢幻自然的四季變幻秘境,秋冬季節金黃松林最為壯觀。
  • 台中海洋館 — 充滿知識與驚奇的海底世界,適合親子共遊與生態教育。

景點推薦Fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".ui.places.Fragment1">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:orientation="vertical">


        <TextView
            android:id="@+id/textView_th"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:text="台中景點"
            android:textColor="@color/SHION"
            android:textStyle="bold"
            android:gravity="center"
            android:textSize="25sp"
            android:background="@color/HUSHULIAN"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView_zbo"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/zbo" />

        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical">


            <ImageView
                android:id="@+id/imageView_lrs"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/lrs" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:layout_marginBottom="30dp"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView_hy"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/hy" />
        </LinearLayout>

    </LinearLayout>
</FrameLayout>

景點推薦Fragment.java

package com.example.ittext.ui.places;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.ittext.R;

public class Fragment1 extends Fragment {
    private TextView THtextView;
    private ImageView HyimageView,LrsimageView,ZboimageView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_1, container, false);
    }
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState){
        super.onViewCreated(view,savedInstanceState);
        THtextView = view.findViewById(R.id.textView_th);
        HyimageView = view.findViewById(R.id.imageView_hy);
        LrsimageView = view.findViewById(R.id.imageView_lrs);
        ZboimageView = view.findViewById(R.id.imageView_zbo);


        ZboimageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDialog("麗寶樂園", "麗寶樂園簡介:\n" +
                        "麗寶樂園位於台中市后里區,是一個結合主題樂園、購物中心和度假村的綜合娛樂場所。這裡有各種刺激的遊樂設施,如雲霄飛車、水上樂園和兒童遊樂區,適合全家大小一同前來享受歡樂時光。\n\n" +
                        "地址: 台中市后里區福容路8號\n" +
                        "營業時間: 週一至週日 10:00 - 18:00\n" +
                        "門票價格: 成人票 NT$899,兒童票 NT$699\n" +
                        "交通方式: 可搭乘台鐵至后里站,轉乘接駁車前往麗寶樂園。");
            }
        });

        HyimageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDialog("台中海洋館", "台中海洋館簡介:\n" +
                        "台中海洋館位於台中市,是一個展示海洋生物和生態的教育性場所。這裡有各種海洋生物展覽,包括魚類、珊瑚、海龜等,並設有互動區域讓遊客能夠近距離觀察和了解海洋生態。\n\n" +
                        "地址: 台中市清水區海洋路 168 號\n" +
                        "營業時間: 週一至週日 10:00-18:00,週二休館\n" +
                        "交通方式: 可搭乘公車至台中市政府站,步行約10分鐘即可抵達台中海洋館。");
            }
        });

        LrsimageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDialog("落羽松", "落羽松簡介:\n" +
                        "落羽松位於台中市后里區(通常稱為「泰安羽粼落羽松」),是一個以自然景觀與生態保育為主題的觀賞園區。這裡有大片落羽松林、水道景觀與步道,提供遊客一個寧靜的環境來散步、拍照與感受季節變化之美。\n\n" +
                        "地址: 台中市后里區安眉路5號\n" +
                        "營業時間:每日 09:00 ~ 17:30\n" +
                        "門票價格: 新台幣 60 元/人;120 公分以下兒童免票\n" +
                        "交通方式: 可搭乘區間車至泰安車站,步行或轉乘接駁至園區");

            }
        });

    }

    private void showDialog(String title, String message) {
        new AlertDialog.Builder(requireContext())
                .setTitle(title)
                .setMessage(message)
                .setPositiveButton("確定", null)
                .show();
    }
}

下一篇,「行程管家」終於要上線工作啦將整合 Google Maps,實現一鍵導航、收藏喜愛景點,並能加入專屬的旅程規劃清單。旅程,從這裡開始!


上一篇
Day 21 行程管家的外貌:讓旅程啟航的景點推薦
系列文
結合AI Agent技術打造自己的行程管家22
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言